package DemoReview;

import java.util.Scanner;

public class NowCoderDP34 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), q = in.nextInt();
        int[] arr = new int[n];
        long[] ds = new long[n + 1];
        ds[0] = 0;
        for (int i = 0; i < n; i++) arr[i] = in.nextInt();
        for (int i = 1; i <= n; i++) {
            ds[i] = ds[i - 1] + arr[i - 1];
        }
        for (int i = 0; i < q; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            System.out.println(ds[b] - ds[a - 1]);
        }
    }
}
